package com.aiyun.elasticjest.domain;


import java.io.Serializable;
import java.util.Date;

import javax.validation.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.GeoPointField;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;

@Document(indexName = "cat", shards = 1, type = "_doc")
@Data
public class Cat implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	private String id;

	@NotEmpty(message = "名称不能为空")
	@Field(type = FieldType.Keyword)
	private String name;

	@Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd")
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
	private Date birthday;

	@GeoPointField
	private GeoPoint location;
}
